package com.rogo.mini.component
{
	import com.rogo.mini.core.VisualElement;
	
	import flash.geom.Rectangle;
	
	/**
	 * Mini Component Framework
	 * 
	 * @author Rogo
	 */	
	public class Group extends VisualElement
	{
		public function Group()
		{
			super();
		}
		
		//--------------------------------------------------------------------------
		//
		//  Properties
		//
		//--------------------------------------------------------------------------
		
		private var hScrollBar:HScrollBar;
		
		private var _clipContent:Boolean = true;

		public function get clipContent():Boolean
		{
			return _clipContent;
		}

		public function set clipContent(value:Boolean):void
		{
			if (_clipContent != value)
			{
				_clipContent = value;
				invalidateDisplayList();
			}
		}

		
		//--------------------------------------------------------------------------
		//
		//  Methods
		//
		//--------------------------------------------------------------------------
		
		override protected function updateElement():void
		{
			hScrollBar = new HScrollBar();
			addElement(hScrollBar);
		}
		
		override protected function updateDisplayList():void
		{
			// clip content
			if (clipContent)
			{
				var rect:Rectangle = new Rectangle(0, 0, width, height);
				s.scrollRect = rect;
			}
			else 
				s.scrollRect = null;
			
			// Horizontal Scroll Bar
			hScrollBar.width = width;
			hScrollBar.height = 15;
			hScrollBar.y = height - 15;
		}
		
	}
}